﻿#ifndef PST_THREEDSURFACEPLOTSIDEBARSETTINGS_H
#define PST_THREEDSURFACEPLOTSIDEBARSETTINGS_H

#include <QWidget>
#include <QScrollArea>
#include <QMouseEvent> 
#include <QListView>
#include <QListWidget>
#include <QSize>
#include <QRect>
#include <QModelIndex>
#include <QStringList>
#include "InfomationGraph3DBasical.h"

QT_BEGIN_NAMESPACE
namespace Ui { class ThreeDSurfacePlotSidebarSettings; };
class QTabWidget;
class QLineEdit;
class QComboBox;
class QListView;
class QVBoxLayout;
class QStandardItem;
QT_END_NAMESPACE

namespace pst
{
    class ThreeDSurfacePlotSidebarData;
    class ThreeDSurfacePlotSidebarSettings : public QScrollArea
    {
        Q_OBJECT
    public:
        ThreeDSurfacePlotSidebarSettings(QWidget* parent = nullptr);
        ~ThreeDSurfacePlotSidebarSettings();

        void setMainWiondowId(int id);
        //QListWidgetItem* addCurveToList(const QString& curveName);

        //void setResultData(const QStringList& resultDataList);
        //QStringList getResultDataList();
        //void setCurrentResultData(const QString& resultData);
        //QString getCurrentResultData();

        QListWidgetItem* addData(InfomationGraph3DBasical* info);

        //void setSlicePositionEnum(const QList<double>& xSliceEnum,
            //const QList<double>& ySliceEnum, const QList<double>& zSliceEnum);
        // 更新数值和更新交互（如Enabled）
        void updateInfoDataAndInterfaceToUI(ThreeDSurfacePlotSidebarData* data);
        // 只更新数值，不更新交互（如Enabled）
        void updateInfoValueToUI(ThreeDSurfacePlotSidebarData* data);
        // 设置控制面板是否可编辑
        void setControlPanelEditable(bool enable);
        void clearControlPlane();
        QListWidget* getCurveNameListWidget();

        // 设置控制面板是否为动画状态，动画状态下不可编辑
        void setControlPlaneToAnimationState(bool isAnimationState);

    public://python调用
        void pyCurveNameClicked(QList<int> selectedIndexs);
        void pyFrequencyChanged(int index);
        void pyResultDataChanged(int index);
        void pyDataOprationChanged(bool isLoged, bool isNormalized);
        void pyItemCheckStateChanged(int itemIndex, bool visible);
        void pyDelete3DSurfacePlots(QString selectedIndexs);
        void pyThreeDSurfaceCurveDataFileterRadioButtonClicked(int windowId, int index);

    private:
        void addTopTabPivotUI();
        void addCurveListUI();

        void addDataOptrationUI();
        void hideComponents();

        void updateGroupRadioButtonUI(ThreeDSurfacePlotSidebarData* data);

    signals:
        void signal_chosenItemsChanged(const QList<QListWidgetItem*>& itemList);
        void siganl_showHideItemActor(QListWidgetItem* item);
        void siganl_graphNameDoubleClicked(QListWidgetItem* item);
        void signal_updateActorValue(ThreeDSurfacePlotSidebarData* data);
        void signal_updateActorOriginalData(ThreeDSurfacePlotSidebarData* data);
        void signal_updateMathOperation(ThreeDSurfacePlotSidebarData* data);
        void signal_deleteChosenGraphs(const QList<QListWidgetItem*>& itemList);
        void signal_getSidebarCurveDataSource(QListWidgetItem* item, QString& dataSource);
        void signal_renameCheck();//重命名结果检查

    public slots:
        void slot_curveNameClicked();
        void slot_itemCheckStateChanged(QListWidgetItem* item);
        void slot_itemDoubleClicked(QListWidgetItem* item);
        void slot_resultDataChanged(int index);
        void slot_frequencyChanged(int index);
        void slot_normalizeClicked(bool checked);
        void slot_logClicked(bool checked);
        void on_pushButton_FormulaEditor_clicked();
        void slot_addCustomContextMenu(const QPoint& pos);

        void on_radioButton_Amplitude_clicked(bool savePy = true);     // 幅度
        void on_radioButton_Phase_clicked(bool savePy = true);     // 相位
        void on_radioButton_RealPart_clicked(bool savePy = true);      // 实部
        void on_radioButton_ImaginaryPart_clicked(bool savePy = true); // 虚部

        void slot_renameItem();
    private:
        void connectSignalsAndSlots();
        void disconnectSignalsAndSlots();

    private:
        int m_mainWindowId;
        Ui::ThreeDSurfacePlotSidebarSettings* ui;
        int _titleFontSize;
        QPair< InfomationGraph3DBasical*, QListWidgetItem* > m_currentChosenItem;
        QList<QPair<InfomationGraph3DBasical*, QListWidgetItem*>> m_allAddedDataList;
        ThreeDSurfacePlotSidebarData* m_currentItemData;

        QVector<bool> m_enableStatus;
    };

}

#endif
